package com.wskeee.ec.components
{
	import com.wskeee.ec.components.skin.RadioButtonSkin;

	public class RadioButton extends Button
	{
		private var _groupName:String;
		private var _group:RadioButtonGroup;
		private var _value:Object;
		
		public function RadioButton()
		{
			super();
			_toggle = true;
			groupName = "defaultRadioGroup";
		}
		
		//========================= override ====================
		/**
		 * 从组中删除 
		 * 
		 */		
		override public function destory():void
		{
			group.remove(this);
			super.destory();
		}
		//========================= end =========================
		
		//========================= utils =======================
		override protected function onButtonMouseUp():void
		{
			if(_selected == false)
				selected = true;
		}
		//========================= end =========================
		

		//========================= get & set ===================
		public function get group():RadioButtonGroup
		{
			return _group;
		}
		
		public function get groupName():String
		{
			return _groupName;
		}
		
		public function set groupName(value:String):void
		{
			_groupName = value;
			if(group)
				group.remove(this);
			_group = RadioButtonGroup.getGroup(value);
			_group.add(this);
		}
		
		public function get value():Object
		{
			return _value ? _value : label;
		}
		
		public function set value(value:Object):void
		{
			_value = value;
		}
		
		override public function get toggle():Boolean
		{
			return true;
		}
		
		//---------------------
		//override skinableComponent
		//---------------------
		override public function get DefaultSkinDrawer():Class
		{
			return RadioButtonSkin;
		}
		//========================= end =========================
	}
}